
import axios from 'axios';

const require = {    
   
    // get    
    get (url,params,res) {     
        axios.get(url, {            
            params: params        
            }).then(res => {
                res(res.data);
            }).catch(err =>{
                res(err.data)        
        });    
    },
    // post提交    
    post (url,params,callback) {     
        axios({
            method: 'post',
            url: url,
            data: params,
            timeout: 10000,
            headers:{
                'Content-Type':'application/json;charset=UTF-8'
               // 'Authorization':Store.getToken()
            }
            }).then(res=>{
                callback(res.data);
            }).catch(err=>{
                console.log(err)
                callback(err);
        });     
    }
   
}

axios.interceptors.request.use(
    config => {
      if (localStorage.getItem('Authorization')) {
        config.headers.Authorization = localStorage.getItem('Authorization');
      }
   
      return config;
    },
    error => {
      return Promise.reject(error);
    });

export default require;